/*
*
* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2011-2018 ARM or its affiliates
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "acamera_command_api.h"
#include "acamera_firmware_settings.h"
// created from 2016-10-19T16:42:58.865Z UTClinear.json

// CALIBRATION_LIGHT_SRC
static uint16_t _calibration_light_src[][2] = {
    {287,242}};

// CALIBRATION_RG_POS
static uint16_t _calibration_rg_pos[]
 = {166,181,198,216,233,256,268,285,303,320,337,355,372,390,426};

// CALIBRATION_BG_POS
static uint16_t _calibration_bg_pos[]
 = {163,183,192,202,211,220,230,239,248,256,267,276,285,295,318};

// CALIBRATION_MESH_RGBG_WEIGHT
static uint16_t _calibration_mesh_rgbg_weight[][15] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 14 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 14, 47, 128, 256, 214 },
  { 0, 0, 0, 0, 0, 0, 0, 2, 6, 22, 65, 162, 256, 256, 7 },
  { 0, 0, 0, 0, 0, 1, 3, 12, 37, 95, 201, 256, 256, 119, 0 },
  { 0, 0, 0, 0, 0, 4, 14, 51, 117, 227, 256, 256, 175, 13, 0 },
  { 0, 0, 0, 0, 2, 23, 57, 148, 252, 256, 256, 191, 32, 1, 0 },
  { 0, 0, 0, 0, 11, 97, 180, 256, 256, 256, 177, 32, 2, 0, 0 },
  { 0, 0, 0, 4, 50, 243, 256, 256, 256, 174, 37, 3, 0, 0, 0 },
  { 0, 0, 1, 29, 160, 256, 256, 256, 162, 38, 4, 0, 0, 0, 0 },
  { 0, 0, 7, 109, 256, 256, 256, 183, 39, 5, 0, 0, 0, 0, 0 },
  { 0, 0, 56, 256, 256, 256, 128, 24, 2, 0, 0, 0, 0, 0, 0 },
  { 0, 3, 256, 256, 256, 71, 20, 2, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 25, 256, 256, 94, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 256, 248, 55, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 8, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};

// CALIBRATION_MESH_LS_WEIGHT
static uint16_t _calibration_mesh_ls_weight[][15] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 3, 4, 25, 42, 53, 57, 53, 42, 25, 4, 3, 0, 0 },
  { 0, 0, 4, 131, 157, 179, 193, 198, 193, 179, 157, 131, 4, 0, 0 },
  { 0, 0, 25, 157, 188, 214, 232, 238, 232, 214, 188, 157, 25, 0, 0 },
  { 0, 0, 42, 179, 214, 243, 255, 256, 255, 243, 214, 179, 42, 0, 0 },
  { 0, 0, 53, 193, 232, 255, 256, 256, 256, 255, 232, 193, 53, 0, 0 },
  { 0, 0, 57, 198, 238, 256, 256, 256, 256, 256, 238, 198, 57, 0, 0 },
  { 0, 0, 53, 193, 232, 255, 256, 256, 256, 255, 232, 193, 53, 0, 0 },
  { 0, 0, 42, 179, 214, 243, 255, 256, 255, 243, 214, 179, 42, 0, 0 },
  { 0, 0, 25, 157, 188, 214, 232, 238, 232, 214, 188, 157, 25, 0, 0 },
  { 0, 0, 4, 131, 157, 179, 193, 198, 193, 179, 157, 131, 4, 0, 0 },
  { 0, 0, 3, 4, 25, 42, 53, 57, 53, 42, 25, 4, 3, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};

// CALIBRATION_MESH_COLOR_TEMPERATURE
static uint16_t _calibration_mesh_color_temperature[][15] = {
  { 154, 169, 186, 204, 222, 247, 254, 279, 299, 317, 335, 349, 362, 379, 385 },
  { 154, 160, 176, 194, 212, 237, 250, 269, 288, 306, 324, 341, 354, 370, 385 },
  { 154, 155, 172, 190, 207, 232, 245, 260, 283, 301, 320, 337, 350, 365, 385 },
  { 147, 154, 167, 185, 202, 227, 240, 256, 278, 296, 314, 333, 346, 361, 385 },
  { 141, 154, 163, 181, 198, 222, 235, 252, 273, 292, 310, 329, 343, 356, 385 },
  { 135, 151, 159, 177, 194, 218, 231, 249, 269, 287, 305, 324, 339, 353, 385 },
  { 133, 144, 154, 172, 189, 213, 226, 244, 264, 282, 300, 319, 335, 349, 385 },
  { 133, 138, 154, 168, 185, 208, 221, 239, 259, 277, 295, 314, 332, 345, 385 },
  { 126, 133, 150, 164, 181, 204, 216, 235, 255, 272, 290, 309, 328, 342, 373 },
  { 121, 133, 145, 160, 177, 200, 212, 231, 252, 268, 286, 305, 323, 339, 369 },
  { 113, 125, 137, 155, 172, 194, 207, 225, 244, 263, 280, 300, 318, 334, 364 },
  { 106, 119, 133, 150, 167, 190, 202, 220, 240, 262, 276, 295, 313, 332, 360 },
  { 100, 112, 126, 144, 163, 186, 198, 216, 235, 258, 271, 290, 308, 327, 354 },
  { 100, 105, 119, 137, 158, 181, 193, 211, 230, 253, 266, 285, 303, 322, 350 },
  { 100, 100, 100, 117, 139, 170, 182, 199, 218, 237, 262, 273, 291, 310, 341 }};

// RG, BG, MULT. final wb gain adjuster for a sky scene. devided by CALIBRATION_WB_STRENGTH_MULT in use
static uint16_t _calibration_wb_strength[] = {1000, 1000, 1000};

// lux threshold for sky
static uint16_t _calibration_sky_lux_th[] = {10000};

// 1D rg/bg readout from color_temp
static uint16_t _calibration_ct_rg_pos_calc[]
 = {181,204,219,256,295,304,358,382,407};

// 1D rg/bg readout from color_temp
static uint16_t _calibration_ct_bg_pos_calc[]
 = {304,284,274,256,239,235,209,196,184};

// CALIBRATION_COLOR_TEMP
static uint16_t _calibration_color_temp[]
 = {100,133,154,200,250,263,333,357,385};

// CALIBRATION_CT65POS
static uint16_t _calibration_ct65pos[] = {2};

// CALIBRATION_CT40POS
static uint16_t _calibration_ct40pos[] = {8};

// CALIBRATION_CT30POS
static uint16_t _calibration_ct30pos[] = {6};

// CALIBRATION_EVTOLUX_EV_LUT
static uint32_t _calibration_evtolux_ev_lut[] //evlog2
 = {0};

// CALIBRATION_EVTOLUX_LUX_LUT
static uint32_t _calibration_evtolux_lux_lut[]
 = {0};

// CALIBRATION_BLACK_LEVEL_R
static uint16_t _calibration_black_level_r[][2] = {
    {0, 258},
    {32, 258},
    {64, 258},
    {96, 258},
    {128, 258}};

// CALIBRATION_BLACK_LEVEL_GR
static uint16_t _calibration_black_level_gr[][2] = {
    {0, 258},
    {32, 258},
    {64, 258},
    {96, 258},
    {128, 258}};

// CALIBRATION_BLACK_LEVEL_GB
static uint16_t _calibration_black_level_gb[][2] = {
    {0, 258},
    {32, 258},
    {64, 258},
    {96, 258},
    {128, 258}};

// CALIBRATION_BLACK_LEVEL_B
static uint16_t _calibration_black_level_b[][2] = {
    {0, 258},
    {32, 258},
    {64, 258},
    {96, 258},
    {128, 258}};

// CALIBRATION_STATIC_WB
static uint16_t _calibration_static_wb[]
 = {412,256,256,388};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_a_ccm[]
 = {478,32915,32843,32862,503,32921,32826,33147,693};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_d40_ccm[]
 = {529,33018,32791,32858,523,32945,32801,33128,649};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_d50_ccm[]
 = {535,33032,32783,32845,515,32950,32788,33088,596};

// CALIBRATION_SHADING_LS_A_R
static uint8_t _calibration_shading_ls_a_r[]
 = {160,151,143,137,132,127,123,118,113,109,105,101,98,95,94,92,92,93,94,95,98,102,105,109,113,118,122,126,130,135,140,146,155,147,139,133,127,122,117,112,107,102,98,93,90,87,85,84,83,84,85,87,90,94,98,102,107,112,117,122,126,131,136,142,150,143,136,130,124,119,113,107,102,96,91,87,83,80,77,76,76,76,77,80,83,87,91,96,102,107,113,118,123,128,133,139,147,140,133,126,120,114,109,103,96,91,85,80,76,73,70,69,68,69,70,72,76,80,85,90,96,102,108,114,119,125,130,136,144,137,130,123,117,111,104,97,91,84,79,73,69,66,63,62,61,62,63,66,69,74,78,84,91,97,104,110,116,122,128,134,142,134,128,121,114,107,100,92,85,79,72,67,63,60,57,56,56,56,57,60,63,67,72,79,85,92,99,106,113,119,125,132,140,132,125,118,111,103,95,88,80,73,67,62,57,54,52,51,51,51,52,54,58,62,67,73,80,87,95,102,110,117,122,129,137,129,122,115,108,99,91,83,75,68,62,57,53,50,48,47,46,47,48,50,53,57,62,68,75,83,91,99,107,113,120,127,136,128,120,113,105,96,87,79,71,64,58,53,49,46,44,43,43,43,44,46,49,53,58,63,71,78,87,95,103,111,118,126,134,125,118,110,102,93,84,75,67,60,54,49,46,43,41,40,40,40,41,43,46,49,54,60,67,75,83,92,101,109,116,124,133,124,117,108,99,90,81,72,64,57,51,46,43,40,39,38,37,38,39,40,43,47,51,57,63,72,80,89,98,107,114,123,132,123,115,106,97,88,78,69,61,54,48,44,41,38,37,36,35,36,37,38,41,44,48,54,61,69,78,87,96,105,113,122,132,122,114,104,96,86,76,67,59,52,47,43,39,37,35,34,34,34,35,37,39,42,47,52,59,67,76,85,95,103,112,121,132,122,113,104,94,85,75,65,57,51,45,41,38,36,34,33,33,33,34,36,38,41,45,51,57,65,74,84,93,102,111,121,131,121,112,103,93,83,74,64,56,50,45,40,37,35,34,33,32,33,34,35,37,40,44,50,56,64,73,83,93,102,111,120,131,121,112,102,93,83,73,64,56,49,44,40,37,35,33,32,32,32,33,35,37,40,44,49,56,63,73,82,92,101,110,121,131,121,112,103,93,83,73,64,56,49,44,40,37,35,33,32,32,32,33,35,37,40,44,49,55,63,73,82,92,102,110,120,131,121,112,103,93,83,73,64,56,50,44,40,37,35,33,33,32,33,33,35,37,40,44,49,56,64,73,83,93,102,111,121,131,122,113,104,94,85,75,65,57,51,45,41,38,36,34,33,33,33,34,36,38,41,45,50,57,65,74,84,93,102,112,122,132,122,114,105,96,86,76,67,59,52,47,43,39,37,35,34,34,34,35,37,39,42,47,52,58,66,75,85,95,104,113,123,133,123,115,106,98,88,79,69,61,54,49,44,41,38,37,36,35,36,37,38,41,44,48,54,61,69,78,87,96,105,114,123,134,125,118,108,100,91,82,72,64,57,51,47,43,41,39,38,37,38,39,40,43,46,51,56,63,71,80,90,99,107,115,124,135,127,119,111,103,93,85,76,67,60,54,49,46,43,41,40,40,40,41,43,46,49,53,59,66,74,83,92,101,110,117,126,137,129,122,114,106,97,88,79,71,64,58,53,49,46,44,43,43,43,44,46,49,52,57,63,70,78,87,95,104,112,119,127,139,131,124,117,108,101,92,84,76,68,62,57,53,50,48,47,46,46,48,50,53,56,61,67,75,82,91,99,107,114,121,128,141,133,127,120,112,104,96,89,81,74,67,62,58,54,52,51,50,51,52,54,57,61,66,72,79,87,95,103,110,118,124,130,144,137,130,123,116,109,101,93,86,79,73,67,63,60,57,56,55,56,57,59,62,66,72,78,85,92,99,107,114,120,126,132,147,139,132,126,119,113,105,99,92,85,79,74,69,66,63,62,61,62,63,65,68,73,78,84,90,97,104,110,117,123,128,134,149,142,136,130,123,117,111,104,97,91,86,81,76,73,70,69,68,69,70,72,75,79,84,89,96,102,108,114,120,126,131,137,153,145,139,133,127,122,116,110,104,98,92,88,84,80,77,76,75,76,77,80,82,86,90,95,101,107,112,118,124,129,134,140,158,150,142,137,131,126,120,115,110,104,99,94,91,87,85,83,83,84,85,87,90,93,97,101,106,112,117,122,127,132,137,143,164,155,147,141,136,130,126,121,116,111,107,103,99,96,94,92,92,92,94,95,98,101,105,108,113,118,122,126,131,136,140,146};

// CALIBRATION_SHADING_LS_A_G
static uint8_t _calibration_shading_ls_a_g[]
 = {144,136,129,124,118,114,110,105,101,97,93,90,87,85,83,82,82,82,83,85,87,90,93,97,101,105,109,113,117,123,127,132,140,132,125,120,114,109,105,100,95,91,87,84,81,78,76,75,75,75,76,78,81,83,87,91,95,100,104,109,113,118,123,129,136,129,123,116,111,106,100,95,90,86,82,78,75,72,70,69,69,69,70,72,75,78,82,86,90,95,100,105,110,115,120,126,133,126,120,113,107,102,96,91,86,81,77,73,69,67,65,63,63,64,65,67,69,73,76,81,86,91,96,101,107,112,117,123,130,123,117,110,104,98,92,86,81,76,72,68,64,61,59,58,57,58,59,61,64,67,71,76,81,86,92,97,103,109,115,121,129,121,114,107,101,95,88,82,77,71,67,62,59,56,54,53,53,53,54,56,59,62,66,72,77,82,88,94,100,106,112,119,126,119,112,105,98,91,85,79,73,67,62,58,54,52,50,49,48,49,50,52,54,58,62,67,72,78,84,91,97,103,109,116,124,116,109,102,95,88,82,75,69,63,58,54,50,48,46,45,45,45,46,48,51,54,58,63,69,75,81,88,94,101,107,114,122,114,107,100,93,85,78,72,65,59,54,50,47,45,43,42,42,42,43,45,47,50,54,59,65,71,78,85,91,98,105,112,121,113,105,97,90,83,76,69,62,56,51,47,44,42,40,39,39,39,40,42,44,48,51,56,62,68,75,82,89,96,103,111,120,111,104,95,88,81,73,66,59,54,49,45,42,40,38,37,37,37,38,40,42,45,49,53,59,65,73,80,87,94,101,109,119,110,102,94,86,79,71,64,57,51,47,43,40,38,36,35,35,36,36,38,40,43,47,51,57,63,70,78,85,93,100,108,118,109,101,93,85,77,69,62,55,50,45,42,39,36,35,34,34,34,35,36,39,41,45,50,55,62,69,76,84,92,99,107,118,108,100,92,84,76,68,61,54,49,44,40,38,35,34,33,33,33,34,35,38,40,44,48,54,60,67,75,83,90,98,107,117,107,99,91,83,75,67,60,53,48,43,40,37,35,33,33,32,33,33,35,37,40,43,48,53,59,67,74,82,90,97,106,117,107,99,91,83,75,67,59,53,47,43,39,37,34,33,32,32,32,33,34,37,39,43,47,52,59,66,74,82,89,97,106,116,107,99,90,82,74,67,59,53,47,43,39,37,34,33,32,32,32,33,34,37,39,43,47,52,59,66,74,82,90,97,106,117,107,99,91,83,75,67,60,53,48,43,40,37,35,33,33,32,32,33,35,37,40,43,47,53,59,67,74,82,90,98,107,117,108,100,92,84,76,68,61,54,49,44,41,38,35,34,33,33,33,34,35,37,40,44,48,54,60,67,75,83,91,98,107,118,109,101,93,85,77,69,62,55,50,45,42,39,37,35,34,34,34,35,36,39,41,45,49,55,61,69,76,84,91,99,108,119,110,102,94,86,79,72,64,57,52,47,43,40,38,36,36,35,35,36,38,40,43,47,51,57,63,70,78,85,93,100,109,120,111,104,96,88,81,74,66,60,54,49,45,42,40,38,37,37,37,38,40,42,45,49,53,59,65,72,80,87,94,102,110,121,113,106,98,91,83,76,69,62,57,52,48,45,42,40,39,39,39,40,42,44,47,51,56,62,68,75,82,89,96,103,111,123,115,108,100,93,86,79,72,66,60,55,51,47,45,43,42,42,42,43,45,47,50,54,59,65,71,78,85,92,98,105,113,125,117,110,103,96,89,82,76,69,63,58,54,51,48,46,45,45,45,46,48,50,53,58,62,68,75,81,88,95,101,108,115,128,120,113,106,99,92,86,79,73,68,62,58,55,52,50,49,48,49,50,52,54,57,62,67,72,78,84,91,98,104,110,117,130,123,116,109,103,96,90,83,78,72,67,63,59,56,55,53,53,53,54,56,58,62,66,71,76,82,88,94,101,107,112,119,132,125,119,112,106,100,94,88,82,77,72,68,64,62,60,58,58,58,59,61,64,67,71,76,81,86,92,98,104,109,115,121,135,128,122,116,110,104,98,92,87,82,77,73,70,67,65,64,63,64,65,67,69,72,76,80,85,90,96,101,107,113,118,124,139,132,125,120,114,108,103,97,92,87,83,79,76,73,71,70,69,70,71,72,75,78,81,85,90,95,100,105,111,116,121,127,143,136,129,123,118,112,107,102,97,92,88,85,82,79,77,76,75,76,77,78,81,83,86,90,95,100,104,109,114,119,124,129,148,140,133,127,122,117,112,108,103,98,95,92,88,86,84,82,82,82,83,85,87,90,92,96,100,105,109,114,118,123,127,132};

// CALIBRATION_SHADING_LS_A_B
static uint8_t _calibration_shading_ls_a_b[]
 = {141,132,125,120,114,109,104,100,96,92,89,86,83,81,80,79,79,79,80,81,83,86,88,92,96,100,104,108,112,118,123,129,136,128,120,116,110,105,100,95,91,87,83,80,77,75,73,73,72,73,73,75,77,80,83,86,90,95,99,103,108,113,119,125,133,125,118,111,106,101,95,91,86,82,78,75,72,70,68,67,67,67,68,69,71,74,78,81,85,90,95,99,105,110,115,122,130,122,115,108,102,96,91,86,82,77,73,70,66,64,62,61,61,61,62,64,66,70,73,76,81,86,91,96,101,107,112,118,127,119,112,105,98,93,87,82,77,72,68,64,62,59,57,56,56,56,57,59,61,65,68,72,77,82,86,92,98,103,109,116,124,116,109,103,96,89,83,78,73,68,64,60,57,54,53,52,51,52,53,54,57,60,64,68,73,78,83,89,95,101,107,113,123,114,107,100,93,86,80,74,69,64,60,56,53,50,48,48,47,48,49,50,53,56,60,64,69,74,80,85,91,98,104,111,121,112,105,97,90,84,78,72,66,60,56,52,49,47,45,44,44,44,45,47,49,52,56,60,65,71,77,83,89,95,102,109,119,110,103,95,88,81,75,69,62,57,53,49,46,44,42,41,41,41,42,44,46,49,53,57,62,68,74,80,86,93,100,107,117,108,101,93,86,79,72,66,60,54,50,46,43,41,40,39,39,39,40,41,44,46,50,54,59,65,71,78,84,91,98,105,115,107,99,91,84,77,70,63,57,52,48,44,41,39,38,37,37,37,38,39,41,44,48,52,57,63,69,75,82,89,96,104,115,106,98,90,82,76,68,62,55,50,46,42,39,37,36,35,35,35,36,38,40,42,46,50,55,61,67,74,81,88,95,102,114,105,97,88,81,74,67,60,54,49,45,41,38,36,35,34,34,34,35,36,38,41,44,48,53,59,66,73,80,87,94,102,113,104,96,88,80,73,66,59,53,48,44,40,37,35,34,33,33,33,34,35,37,40,43,47,52,58,64,72,79,86,93,101,113,103,95,87,80,72,65,58,52,47,43,39,37,35,33,32,32,32,33,34,37,39,42,46,51,57,64,71,78,85,92,101,112,103,95,87,79,72,64,58,52,47,42,39,36,34,33,32,32,32,33,34,36,39,42,46,51,57,63,71,78,85,93,101,113,103,95,87,79,72,65,58,52,47,43,39,36,34,33,32,32,32,33,34,36,39,42,46,51,56,63,71,78,85,92,101,113,103,95,87,80,72,65,58,52,47,43,40,37,35,33,33,32,32,33,34,36,39,42,46,51,57,64,71,78,86,93,101,114,104,96,88,81,73,66,59,53,48,44,40,37,35,34,33,33,33,34,35,37,40,43,47,52,58,64,72,79,86,93,102,114,105,97,89,81,74,67,60,54,49,45,41,38,36,35,34,34,34,35,36,38,41,44,48,53,59,65,73,80,87,94,103,115,106,98,90,83,76,69,62,56,51,46,43,40,38,36,35,35,35,36,38,40,42,46,50,55,60,67,74,81,88,95,104,116,108,100,92,85,78,71,64,58,53,48,45,42,40,38,37,37,37,38,39,41,44,47,52,57,63,69,76,82,89,97,105,118,109,102,94,87,80,73,67,61,55,51,47,44,42,40,39,39,39,40,41,44,46,50,54,59,65,71,78,85,91,98,106,119,111,104,96,89,83,76,69,63,58,53,50,47,44,43,42,41,42,42,44,46,49,53,57,62,68,74,80,87,93,100,107,122,113,106,99,92,85,79,73,67,62,57,53,50,47,46,45,44,45,45,47,49,52,56,60,65,71,77,83,89,96,102,109,124,116,109,102,95,88,82,76,71,65,61,56,53,51,49,48,48,48,49,50,53,56,59,64,69,75,80,86,92,98,104,112,127,119,112,105,98,92,85,80,75,69,65,61,58,55,53,52,52,52,53,54,57,60,63,68,73,78,83,89,95,101,107,114,130,121,114,108,102,95,89,84,79,74,69,66,62,60,58,57,56,57,58,59,61,64,68,72,77,82,87,93,99,104,110,117,132,125,118,111,106,99,93,88,83,79,74,71,67,65,63,62,61,62,63,64,67,69,73,76,81,86,91,96,102,107,113,119,136,128,121,115,109,104,98,93,88,83,80,76,73,70,68,67,67,67,68,70,72,75,78,81,85,90,95,100,106,110,116,123,140,132,124,118,113,108,102,97,92,88,84,81,78,76,74,73,72,73,74,75,77,80,82,86,90,95,99,104,110,114,119,125,144,135,128,122,118,112,107,102,98,94,90,87,84,82,80,79,78,79,80,81,83,86,88,91,95,99,103,109,113,119,123,128};

// CALIBRATION_SHADING_LS_TL84_R
static uint8_t _calibration_shading_ls_tl84_r[]
 = {157,148,140,134,128,124,119,115,111,107,102,99,95,93,91,90,90,90,91,93,95,99,102,107,110,115,118,122,127,131,136,142,152,144,136,130,124,119,115,110,105,100,95,91,88,85,83,81,82,82,83,85,88,91,95,100,104,109,113,118,123,127,133,138,147,139,132,126,121,115,110,105,100,94,89,85,81,78,76,75,74,75,76,78,81,85,89,94,99,104,109,115,120,125,129,135,143,136,130,123,117,112,106,100,94,88,83,79,74,71,69,68,67,67,69,71,74,78,83,88,94,99,106,111,116,122,127,132,141,133,127,121,114,108,102,95,89,83,77,72,68,65,62,61,61,61,62,65,68,72,77,83,88,95,101,107,113,119,124,130,139,131,124,118,111,104,97,91,83,77,71,66,62,59,57,55,55,55,57,59,62,66,71,77,83,90,97,103,109,116,121,128,137,129,122,115,108,101,93,86,79,72,66,61,57,54,52,50,50,50,52,54,57,61,66,72,78,85,92,100,106,113,119,126,135,127,120,112,105,97,89,82,74,67,61,56,52,49,47,46,46,46,47,50,52,56,61,67,74,81,89,96,103,110,117,124,133,125,118,110,102,94,86,78,70,63,57,52,49,46,44,43,42,43,44,46,49,52,57,62,69,77,85,93,100,108,114,122,132,123,115,107,99,91,82,74,66,59,53,49,45,43,41,40,40,40,41,43,45,49,53,59,65,73,81,90,98,105,113,121,130,121,114,105,97,88,79,71,63,56,50,46,43,40,38,38,37,38,39,40,43,46,51,56,62,70,79,87,95,104,111,119,129,120,112,103,95,86,77,68,60,53,48,44,41,38,37,36,35,36,37,38,41,44,48,53,60,67,76,85,93,102,110,118,128,119,111,102,93,84,75,66,58,52,46,42,39,37,35,34,34,34,35,37,39,42,46,51,58,65,74,83,92,101,108,117,128,118,110,101,92,83,73,64,57,50,45,41,38,36,34,33,33,33,34,36,38,41,45,50,56,64,72,82,91,100,108,117,127,117,109,100,91,82,72,63,56,49,44,40,37,35,33,33,32,33,33,35,37,40,44,49,55,63,72,81,90,99,107,117,127,117,109,100,91,81,72,63,55,49,44,40,37,35,33,32,32,32,33,35,37,40,44,49,55,62,71,80,90,99,107,117,127,118,109,100,91,81,72,63,55,49,44,40,37,35,33,32,32,32,33,34,37,40,44,49,55,62,71,81,90,99,107,117,127,118,110,100,91,82,72,63,56,49,44,40,37,35,33,33,32,33,33,35,37,40,44,49,55,63,71,81,90,99,108,117,127,118,110,101,92,83,73,64,57,50,45,41,38,36,34,33,33,33,34,35,38,41,45,50,56,64,72,82,91,100,108,118,128,119,111,102,94,84,75,66,58,52,46,42,39,37,35,34,34,34,35,37,39,42,46,51,58,65,74,83,92,101,110,119,129,120,112,104,95,86,77,68,60,54,48,44,41,38,37,36,35,36,37,38,41,44,48,53,60,67,76,85,94,102,110,119,130,122,114,106,98,89,80,71,63,56,51,46,43,40,39,38,37,38,38,40,43,46,50,55,62,70,78,87,96,104,112,120,132,123,116,108,100,91,83,74,66,59,53,49,46,43,41,40,39,40,41,43,45,49,53,58,65,73,81,90,98,106,113,121,134,126,118,111,103,94,87,78,70,63,57,52,49,46,44,43,42,43,44,46,48,52,56,62,69,77,85,93,101,108,116,123,135,128,121,114,106,98,90,82,74,67,61,56,53,50,47,46,46,46,47,49,52,56,60,66,73,81,89,97,104,111,118,125,138,130,124,117,109,102,94,87,79,72,66,61,57,54,52,50,50,50,51,54,56,60,65,71,78,85,93,100,108,114,120,127,140,133,127,120,113,106,99,92,85,78,72,67,62,59,57,55,55,55,57,59,61,66,71,77,83,90,97,104,111,117,123,129,143,136,129,123,117,110,103,97,90,83,78,73,69,65,63,61,61,61,62,64,68,72,77,82,88,95,101,108,114,120,126,132,146,139,133,126,120,114,108,102,95,89,84,79,75,72,69,68,67,68,69,71,74,78,83,87,93,100,106,112,118,123,128,134,150,142,136,130,124,119,113,107,101,96,91,86,82,79,76,75,74,75,76,78,81,85,89,93,99,105,110,116,121,126,131,137,156,148,139,134,128,123,118,112,107,102,97,93,89,86,84,82,82,82,83,85,88,91,95,99,104,110,115,119,125,129,134,141,162,152,144,138,133,128,124,119,115,110,105,101,97,94,92,90,90,90,92,93,96,99,102,106,110,116,120,124,129,134,138,144};

// CALIBRATION_SHADING_LS_TL84_G
static uint8_t _calibration_shading_ls_tl84_g[]
 = {143,135,128,122,117,112,108,104,100,96,92,89,86,84,82,81,81,81,82,84,86,88,92,95,99,103,107,111,116,120,125,130,139,131,124,119,113,108,103,99,94,90,86,83,80,77,76,75,74,75,76,77,80,82,86,90,94,98,103,107,112,116,121,127,135,128,121,115,110,105,100,94,89,85,81,77,74,72,70,69,69,69,70,72,74,77,81,85,89,94,99,103,108,114,118,124,132,125,119,112,106,101,95,90,85,80,76,72,69,66,64,63,62,63,64,66,68,72,76,80,84,89,95,100,105,110,115,121,129,122,116,109,103,97,91,86,80,75,71,67,63,61,59,57,57,57,59,61,63,67,71,75,80,85,91,96,102,107,113,119,127,120,113,107,100,94,88,82,76,71,66,62,58,56,54,53,52,53,54,56,58,62,66,71,76,81,87,93,99,105,110,117,125,117,111,104,97,90,84,78,72,67,62,57,54,51,50,49,48,49,50,51,54,57,61,66,72,77,83,89,96,102,108,115,123,115,108,101,94,87,81,75,68,63,58,54,50,48,46,45,45,45,46,48,50,53,57,62,68,74,80,86,93,99,106,112,121,113,106,99,92,85,78,71,65,59,54,50,47,45,43,42,42,42,43,45,47,50,54,59,64,70,77,83,90,97,103,111,120,112,104,96,89,82,75,68,62,56,51,47,44,42,40,39,39,39,40,42,44,47,51,56,61,67,74,81,88,95,101,109,119,110,102,95,87,80,73,66,59,53,49,45,42,40,38,37,37,37,38,40,42,45,48,53,58,65,72,79,86,93,100,108,118,109,101,93,85,78,71,63,57,51,47,43,40,38,36,35,35,35,36,38,40,43,46,51,56,63,70,77,84,91,98,106,117,108,100,92,84,77,69,62,55,50,45,41,39,36,35,34,34,34,35,36,38,41,45,49,55,61,68,75,83,90,97,106,116,107,99,91,83,75,68,60,54,48,44,40,38,35,34,33,33,33,34,35,37,40,44,48,53,60,67,74,82,89,96,105,115,106,98,90,82,74,67,59,53,48,43,40,37,35,33,33,32,33,33,35,37,39,43,47,53,59,66,73,81,89,96,104,115,106,98,90,82,74,66,59,53,47,43,39,36,34,33,32,32,32,33,34,36,39,43,47,52,58,66,73,81,88,96,104,115,106,98,90,82,74,66,59,53,47,43,39,36,34,33,32,32,32,33,34,36,39,43,47,52,58,65,73,81,88,96,104,116,106,98,90,82,74,67,59,53,48,43,40,37,35,33,33,32,32,33,35,37,39,43,47,52,59,66,74,81,89,96,105,116,107,99,91,83,75,68,60,54,48,44,40,38,35,34,33,33,33,34,35,37,40,44,48,53,60,67,74,82,89,97,106,116,108,100,92,84,77,69,62,55,50,45,42,39,36,35,34,34,34,35,36,39,41,45,49,55,61,68,76,83,91,98,106,117,109,101,93,86,78,71,64,57,51,47,43,40,38,36,35,35,35,36,38,40,43,46,51,56,63,70,77,85,92,99,108,119,111,103,95,88,80,73,66,59,54,49,45,42,40,38,37,37,37,38,40,42,45,48,53,59,65,72,79,86,93,101,109,121,112,105,97,90,83,76,69,62,56,51,47,44,42,40,39,39,39,40,42,44,47,51,55,61,67,74,81,88,95,102,110,122,114,107,100,92,85,79,72,65,59,54,50,47,45,43,42,42,42,43,45,47,50,54,58,64,71,77,84,91,97,104,112,124,116,110,102,95,88,82,75,69,63,58,54,51,48,46,45,45,45,46,48,50,53,57,62,68,74,80,87,94,100,107,114,127,119,112,106,98,92,85,79,73,67,62,58,54,52,50,49,48,49,50,51,54,57,61,66,72,78,84,90,97,103,109,116,129,122,115,108,102,95,89,83,77,72,67,63,59,56,54,53,53,53,54,56,58,62,66,71,76,82,87,93,100,106,111,118,132,125,118,112,105,99,93,87,82,77,72,68,64,61,59,58,58,58,59,61,63,67,71,75,80,86,91,97,103,109,114,120,134,128,122,115,110,103,98,92,87,82,77,73,70,67,65,64,63,63,65,66,69,72,76,80,85,90,95,101,106,112,117,123,138,131,125,119,113,108,102,97,92,87,83,79,76,73,71,70,69,69,70,72,75,78,81,85,89,94,99,105,110,115,120,126,143,135,128,123,117,112,107,102,97,92,88,85,82,79,77,76,75,75,77,78,81,83,86,90,94,99,104,109,114,119,123,129,147,140,133,127,122,117,112,107,102,98,94,91,88,85,84,82,82,82,83,85,87,90,92,96,99,104,108,113,118,123,127,132};

// CALIBRATION_SHADING_LS_TL84_B
static uint8_t _calibration_shading_ls_tl84_b[]
 = {138,130,125,119,114,109,104,99,95,91,88,85,82,80,78,78,77,78,78,80,82,84,87,90,94,98,103,107,111,116,121,126,135,127,120,114,109,104,99,94,90,86,82,79,76,74,72,72,71,71,72,74,76,79,81,85,89,93,98,103,107,112,117,122,132,124,117,110,105,100,94,90,85,81,77,74,71,69,67,66,66,66,67,69,71,73,76,80,84,89,93,98,103,108,114,120,128,121,114,107,101,96,91,85,81,76,72,69,66,63,62,61,60,61,62,63,66,68,72,76,80,85,90,95,100,105,111,117,125,118,111,104,98,92,86,81,76,72,68,64,61,58,57,56,55,56,57,58,61,64,68,72,76,80,86,91,97,102,108,114,123,115,109,101,95,89,83,77,72,68,64,60,56,54,52,51,51,51,52,54,56,59,63,68,72,77,82,88,93,99,105,112,121,113,106,99,92,86,80,74,69,64,59,56,52,50,48,47,47,48,49,50,52,55,59,63,68,73,79,84,91,96,102,109,119,110,104,96,89,83,77,71,65,60,55,52,49,47,45,44,44,44,45,47,49,52,55,60,65,70,76,81,88,93,100,108,117,109,101,94,87,80,74,68,62,57,52,49,46,44,42,41,41,41,42,44,46,49,52,56,62,67,73,79,85,92,98,105,116,107,99,92,85,78,72,65,59,54,50,46,43,41,40,39,38,39,40,41,43,46,50,54,59,64,70,77,83,89,96,104,115,106,98,90,83,76,70,63,57,52,48,44,41,39,38,37,37,37,38,39,41,44,47,52,56,62,68,75,81,88,94,102,114,104,96,89,81,75,68,61,55,50,46,42,39,37,36,35,35,35,36,37,39,42,46,50,54,60,66,73,80,87,93,101,113,104,95,87,80,73,66,59,54,48,44,41,38,36,35,34,34,34,35,36,38,41,44,48,53,59,65,72,79,85,92,100,113,103,94,87,79,72,65,58,53,48,43,40,37,35,34,33,33,33,34,35,37,40,43,47,52,57,64,71,78,84,91,99,112,102,94,86,79,72,64,58,52,47,43,39,36,35,33,33,32,32,33,34,36,39,42,46,51,57,63,70,77,84,91,99,112,102,94,86,78,71,64,57,51,46,42,39,36,34,33,32,32,32,33,34,36,39,42,46,51,56,63,70,77,84,91,98,111,102,94,86,78,71,64,57,51,47,42,39,36,34,33,32,32,32,33,34,36,39,42,46,51,56,63,70,77,84,91,99,111,102,94,86,79,72,65,58,52,47,43,39,37,35,33,33,32,33,33,35,36,39,42,46,51,57,63,70,77,84,91,100,112,103,95,87,79,72,65,59,53,48,44,40,37,35,34,33,33,33,34,35,37,40,43,47,52,57,64,71,78,85,92,100,113,104,96,87,81,74,67,60,54,49,45,41,38,36,35,34,34,34,35,36,38,41,44,48,53,59,65,72,79,85,93,101,114,105,97,89,82,75,68,61,56,50,46,43,40,38,36,35,35,35,36,38,40,42,46,50,54,60,67,73,80,87,94,102,115,106,98,91,84,77,70,64,58,52,48,44,42,39,38,37,37,37,38,39,41,44,47,51,56,62,68,75,82,89,95,103,116,108,100,93,86,79,73,66,60,55,50,47,44,42,40,39,39,39,40,41,44,46,50,54,59,65,71,77,83,90,97,104,119,110,102,95,88,82,75,69,63,58,53,49,46,44,43,42,41,42,42,44,46,49,52,57,62,68,74,80,86,92,99,106,121,113,105,98,91,84,78,72,66,61,57,53,50,47,46,45,44,44,45,47,49,52,56,60,65,71,76,82,89,95,101,108,123,115,108,101,94,88,81,76,70,65,60,56,53,51,49,48,48,48,49,50,53,56,59,64,69,74,80,86,92,98,104,110,126,118,111,104,97,91,85,79,74,69,64,61,57,55,53,52,52,52,53,54,57,60,63,68,73,78,83,89,95,100,106,113,128,120,114,107,101,95,89,83,78,74,69,65,62,59,58,57,56,56,57,59,61,64,68,72,77,81,87,92,98,103,109,116,131,123,117,111,105,99,93,88,83,78,74,70,67,65,63,62,61,61,62,64,66,69,73,76,81,86,91,96,101,107,112,118,134,127,121,115,109,103,97,92,88,83,79,76,73,70,68,67,67,67,68,70,72,75,78,81,85,90,95,100,105,110,115,122,140,131,124,118,112,107,101,97,92,88,84,81,78,75,74,73,72,73,73,75,77,80,82,86,89,94,99,104,109,114,118,124,144,135,128,122,117,111,106,102,97,93,90,87,84,81,80,79,78,79,80,81,83,85,87,91,94,99,104,108,113,118,122,127};

// CALIBRATION_SHADING_LS_D65_R
static uint8_t _calibration_shading_ls_d65_r[]
 = {154,146,138,131,126,122,118,113,109,105,101,97,94,91,89,89,88,88,89,91,94,97,100,104,108,112,116,120,124,129,134,139,148,141,134,127,122,117,113,108,103,98,94,90,86,83,82,80,80,80,82,84,86,89,93,98,102,107,111,116,120,125,130,135,143,136,130,124,118,113,108,103,98,92,88,83,80,77,75,73,73,73,75,77,80,83,87,92,97,102,107,112,117,122,126,133,140,133,127,121,115,110,104,98,92,87,82,78,73,70,68,67,66,67,68,70,73,77,82,87,92,97,103,108,114,119,124,130,137,131,124,118,112,106,99,93,87,81,76,71,67,64,62,60,60,60,62,64,67,71,76,81,87,93,99,105,110,115,122,128,135,128,122,115,109,102,95,89,82,76,71,65,61,58,56,55,54,55,56,58,61,65,70,76,81,88,95,101,107,113,119,125,133,126,119,112,106,99,91,84,77,71,65,60,56,53,51,50,50,50,51,53,56,60,65,70,77,83,90,98,104,111,116,123,131,123,117,110,103,95,88,80,73,66,60,56,52,49,47,46,46,46,47,49,52,56,60,66,72,79,87,94,101,108,114,121,129,122,115,107,100,92,84,76,69,62,56,52,48,45,44,42,42,43,44,46,48,52,56,62,68,76,83,91,98,105,112,119,129,120,113,105,97,89,81,73,65,58,53,49,45,43,41,40,39,40,41,43,45,49,53,58,64,72,80,88,96,103,110,118,127,119,112,103,95,87,78,70,62,55,50,46,42,40,38,37,37,37,38,40,43,46,50,55,62,69,77,85,94,102,109,117,127,118,109,101,93,84,76,67,60,53,48,44,40,38,36,36,35,36,37,38,40,44,48,53,59,66,75,83,92,100,107,116,125,116,108,100,91,83,73,65,57,51,46,42,39,37,35,34,34,34,35,37,39,42,46,51,57,64,73,82,90,98,106,115,126,116,107,99,90,81,72,64,56,50,45,41,38,36,34,33,33,33,34,36,38,41,45,50,56,63,71,80,89,98,105,114,125,115,107,98,89,80,71,62,55,49,44,40,37,35,33,33,32,33,33,35,37,40,44,49,55,62,70,79,88,97,105,114,125,116,106,98,89,80,70,62,55,48,43,40,37,35,33,32,32,32,33,34,37,40,43,48,54,62,70,79,88,97,105,114,125,115,107,98,89,79,71,62,54,48,43,40,37,35,33,32,32,32,33,34,37,40,43,48,54,62,70,79,88,97,105,114,125,115,107,98,89,80,71,62,55,49,44,40,37,35,33,33,32,33,33,35,37,40,44,49,55,62,70,79,88,97,105,115,125,116,108,99,90,81,72,64,56,50,45,41,38,36,34,33,33,33,34,35,38,41,45,49,56,63,72,80,89,98,106,115,126,117,109,100,92,83,74,65,58,51,46,42,39,37,35,34,34,34,35,37,39,42,46,51,57,65,73,82,91,99,107,116,126,118,110,101,93,85,76,67,59,53,48,44,41,38,37,36,35,36,36,38,40,44,48,53,59,67,75,84,92,100,108,117,127,119,112,104,95,87,78,70,62,56,50,46,43,40,38,37,37,37,38,40,42,46,50,55,62,69,77,86,94,102,109,118,128,121,114,106,98,90,81,73,65,59,53,49,45,43,41,40,39,40,41,42,45,48,53,58,65,72,80,89,96,104,111,119,131,123,116,109,100,93,85,77,69,62,57,52,48,46,44,42,42,42,43,45,48,51,56,61,68,76,84,91,99,107,114,121,133,125,118,112,104,96,89,81,73,67,60,56,52,49,47,46,46,46,47,49,52,55,60,66,72,79,87,95,102,109,115,123,136,128,121,114,108,100,93,85,78,71,66,61,57,54,52,50,50,50,51,53,56,60,65,70,77,84,91,98,106,112,118,125,138,130,124,117,111,104,97,90,83,77,71,66,62,59,56,55,54,55,56,58,61,65,70,76,82,88,95,102,109,115,121,127,141,134,128,121,114,108,102,95,88,82,77,72,68,64,62,61,60,61,62,64,67,71,75,81,87,93,100,106,112,118,124,130,145,138,131,124,119,112,106,100,94,88,83,78,74,71,68,67,67,67,68,70,73,77,82,86,92,98,104,110,116,120,127,133,149,141,134,128,122,117,111,105,100,95,89,85,81,78,76,74,73,74,75,77,80,84,88,92,97,103,108,114,119,124,129,135,154,146,138,132,126,121,116,110,106,101,96,92,88,85,82,81,81,81,82,84,87,90,94,98,103,108,113,118,123,128,133,139,160,151,143,136,130,126,121,116,112,108,104,100,96,93,90,89,89,90,91,92,95,98,101,105,109,114,118,123,127,132,137,144};

// CALIBRATION_SHADING_LS_D65_G
static uint8_t _calibration_shading_ls_d65_g[]
 = {142,134,127,122,116,112,108,103,99,95,91,88,85,83,82,81,80,81,81,83,85,88,91,95,98,103,107,111,115,120,124,129,137,130,124,118,112,108,103,98,94,89,86,82,79,77,75,74,74,74,75,77,79,82,85,89,93,98,102,106,111,116,120,126,133,127,121,114,109,104,99,94,89,85,81,77,74,71,69,68,68,68,69,71,74,77,80,84,89,93,98,103,107,113,118,123,130,123,118,111,106,100,95,90,84,80,75,72,68,65,64,62,62,63,64,65,68,71,75,79,84,89,94,99,104,109,115,121,127,121,115,108,102,96,91,85,80,75,71,66,63,60,58,57,57,57,58,60,63,66,70,75,79,85,90,96,101,107,112,118,125,118,112,106,99,93,87,81,76,70,66,62,58,55,54,52,52,52,54,55,58,61,65,70,75,81,86,92,98,104,109,116,123,116,110,103,96,90,84,78,72,66,61,57,54,51,49,48,48,48,49,51,54,57,61,66,71,77,83,89,95,101,107,114,122,114,107,100,94,87,80,74,68,62,57,53,50,48,46,45,44,45,46,48,50,53,57,62,67,73,79,86,92,98,105,112,120,112,105,98,91,84,77,71,64,59,54,50,47,44,43,42,41,42,43,44,47,50,54,58,64,70,76,83,90,96,102,110,119,111,103,96,89,82,75,68,61,56,51,47,44,42,40,39,39,39,40,42,44,47,51,55,61,67,74,80,87,94,101,108,118,109,102,94,87,79,72,65,59,53,48,45,42,39,38,37,37,37,38,39,42,45,48,53,58,64,71,78,85,92,99,107,117,108,100,92,85,77,70,63,57,51,47,43,40,38,36,35,35,35,36,38,40,43,46,51,56,62,69,76,83,90,98,105,116,107,99,91,83,76,68,61,55,49,45,41,38,36,35,34,34,34,35,36,38,41,45,49,54,61,68,75,82,89,96,105,116,106,98,90,82,75,67,60,54,48,44,40,37,35,34,33,33,33,34,35,37,40,43,48,53,59,66,74,81,88,96,104,115,105,98,90,82,74,66,59,53,47,43,40,37,35,33,33,32,33,33,35,37,39,43,47,52,58,66,73,80,88,95,104,114,105,97,89,81,74,66,59,52,47,43,39,36,34,33,32,32,32,33,34,36,39,42,47,52,58,65,73,80,88,95,103,115,105,97,89,81,74,66,59,52,47,43,39,36,34,33,32,32,32,33,34,36,39,43,47,52,58,65,73,80,88,95,104,115,106,98,90,82,74,66,59,53,47,43,40,37,35,33,33,32,32,33,35,37,39,43,47,52,58,66,73,81,88,96,104,115,106,99,90,83,75,67,60,54,48,44,40,37,35,34,33,33,33,34,35,37,40,44,48,53,59,66,74,82,89,96,105,116,107,100,91,84,76,69,61,55,50,45,42,39,36,35,34,34,34,35,36,38,41,45,49,54,61,68,75,83,90,97,106,117,108,101,93,85,78,71,63,57,51,47,43,40,38,36,35,35,35,36,38,40,43,46,51,56,62,69,77,84,91,98,107,118,110,102,95,87,80,73,66,59,53,49,45,42,40,38,37,37,37,38,40,42,45,48,53,58,65,71,79,86,93,100,108,120,111,104,97,89,83,75,68,62,56,51,47,44,42,40,39,39,39,40,42,44,47,51,55,61,67,74,81,88,95,101,109,121,114,107,99,92,85,78,71,65,59,54,50,47,45,43,42,42,42,43,45,47,50,54,58,64,70,77,84,90,97,104,111,124,116,109,102,95,88,81,75,69,63,58,54,50,48,46,45,45,45,46,48,50,53,57,62,68,74,80,87,93,100,106,113,126,119,112,105,98,91,85,79,73,67,62,58,54,52,50,49,48,49,50,51,54,57,61,66,72,78,84,90,96,103,108,115,128,121,115,108,102,95,89,83,77,72,67,62,59,56,54,53,53,53,54,56,58,62,66,70,76,81,87,93,99,105,111,117,131,124,118,111,105,99,93,87,82,76,72,68,64,61,59,58,58,58,59,61,63,67,71,75,80,85,91,97,103,108,114,120,134,127,121,115,109,103,97,92,87,82,77,73,70,67,65,63,63,63,64,66,69,72,76,80,85,90,95,101,106,111,117,123,137,130,125,119,113,108,102,96,92,87,83,79,75,73,71,69,69,69,70,72,75,78,81,85,89,95,99,104,110,115,120,126,142,135,128,122,117,112,106,101,97,92,88,84,81,79,77,76,75,75,76,78,80,83,86,90,94,99,104,108,113,118,123,129,147,140,132,127,121,117,112,107,103,98,94,91,88,85,83,82,82,82,83,85,87,89,92,96,100,104,109,113,118,123,127,132};

// CALIBRATION_SHADING_LS_D65_B
static uint8_t _calibration_shading_ls_d65_b[]
 = {137,130,123,118,112,107,103,99,94,91,87,84,81,80,78,77,77,77,78,79,81,83,86,90,94,98,102,106,110,116,120,125,134,126,119,114,108,103,98,94,89,85,82,78,76,74,72,71,71,71,72,73,75,78,81,84,89,93,97,102,106,111,116,122,130,123,116,110,104,99,95,89,84,81,77,73,70,68,67,66,66,66,66,68,70,73,76,80,84,88,93,98,103,108,113,119,127,120,113,106,100,95,90,85,80,76,72,68,65,63,61,60,60,60,61,63,65,68,72,75,80,84,89,94,99,104,110,116,125,117,110,104,97,92,86,81,76,71,68,64,61,58,57,55,55,55,56,58,61,64,67,71,75,80,85,90,96,102,107,113,122,114,107,101,94,88,82,77,72,68,63,59,56,54,52,51,51,51,52,54,56,59,63,67,71,76,82,87,93,99,104,111,120,112,105,98,91,85,79,74,68,63,59,55,52,50,48,47,47,47,48,50,52,55,59,63,68,73,78,84,90,96,102,109,118,110,103,95,89,82,76,71,65,60,55,52,49,46,45,44,44,44,45,46,49,52,55,59,64,70,75,81,87,93,99,106,117,108,100,93,86,80,74,68,62,57,52,49,46,43,42,41,41,41,42,44,46,49,52,56,61,67,72,79,85,91,97,104,115,106,99,91,84,78,71,65,59,54,50,46,43,41,40,39,38,39,40,41,43,46,50,54,59,64,70,76,82,89,95,102,114,105,97,89,83,76,69,63,57,52,47,44,41,39,37,37,36,37,38,39,41,44,47,51,56,62,68,74,81,87,94,101,113,104,96,88,81,74,67,61,55,50,46,42,39,37,36,35,35,35,36,37,39,42,45,49,54,60,66,73,79,86,92,100,112,103,95,87,80,73,66,59,53,48,44,41,38,36,35,34,34,34,35,36,38,41,44,48,53,58,65,71,78,85,91,99,112,102,94,86,79,72,65,58,52,47,43,40,37,35,34,33,33,33,34,35,37,40,43,47,52,57,64,70,77,84,91,98,110,101,94,86,78,71,64,57,52,47,43,39,36,35,33,32,32,32,33,34,36,39,42,46,51,57,63,70,77,84,90,98,111,101,93,85,78,71,64,57,51,46,42,39,36,34,33,32,32,32,33,34,36,39,42,46,50,56,63,69,76,83,90,98,111,102,93,85,78,71,64,57,51,46,42,39,36,34,33,32,32,32,33,34,36,39,42,46,50,56,63,70,76,83,90,99,111,102,93,86,78,71,64,57,52,47,43,39,37,35,33,33,32,33,33,35,36,39,42,46,51,57,63,70,77,84,91,99,111,102,94,86,79,72,65,58,52,47,43,40,37,35,34,33,33,33,34,35,37,40,43,47,52,57,64,71,78,85,91,99,112,103,95,87,80,73,66,60,54,49,44,41,38,36,35,34,34,34,35,36,38,41,44,48,53,59,65,72,79,85,92,101,113,104,96,89,82,75,68,61,55,50,46,42,40,38,36,35,35,35,36,38,40,42,46,49,54,60,66,73,80,87,94,101,114,106,98,90,83,77,70,63,57,52,48,44,42,39,38,37,37,37,38,39,41,44,47,51,56,62,68,75,81,88,95,103,116,107,100,92,86,79,72,66,60,55,50,47,44,42,40,39,39,39,40,41,44,46,50,54,59,65,71,77,83,90,96,104,118,109,102,95,88,81,75,69,63,58,53,49,46,44,43,42,41,42,42,44,46,49,52,57,62,67,73,79,85,92,98,106,120,112,104,97,90,84,78,72,66,61,56,53,49,47,46,44,44,44,45,47,49,52,56,60,65,70,76,82,88,94,101,108,122,114,107,100,94,87,81,75,70,65,60,56,53,51,49,48,48,48,49,50,53,56,59,64,69,74,79,85,91,97,103,110,125,117,110,104,97,91,85,79,74,69,64,60,57,55,53,52,52,52,53,54,57,60,63,68,72,77,83,89,94,100,106,112,128,120,113,107,101,94,89,83,78,73,69,65,62,59,58,56,56,56,57,59,61,64,68,72,77,81,86,92,98,103,109,115,131,124,117,111,105,99,93,88,82,78,74,70,67,65,63,62,61,61,62,64,66,69,73,76,81,85,91,96,102,107,112,118,135,127,120,114,109,103,98,92,87,83,79,75,72,70,68,67,67,67,68,69,72,74,77,81,85,90,94,100,105,110,115,121,139,131,124,118,112,107,102,97,92,88,84,81,78,75,73,72,72,72,73,75,77,79,82,86,90,94,99,103,108,114,118,124,143,135,128,122,117,112,107,102,98,93,90,87,84,81,79,78,78,79,79,81,83,85,87,91,95,99,103,108,113,118,123,127};


// R G B
static uint16_t _calibration_awb_warming_ls_a[] = {250, 256, 270};

// R G B
static uint16_t _calibration_awb_warming_ls_d75[] = {265, 256, 260};

// R G B
static uint16_t _calibration_awb_warming_ls_d50[] = {256, 256, 256};

// CALIBRATION_NOISE_PROFILE
static uint8_t _calibration_noise_profile[]
 = {0,0,0,0,0,0,0,0,6,19,25,29,31,34,36,38,39,40,41,43,44,44,45,46,47,47,48,49,49,50,50,51,51,52,52,52,53,53,54,54,54,55,55,55,56,56,56,57,57,57,57,58,58,58,58,59,59,59,59,60,60,60,60,61,61,61,61,61,62,62,62,62,62,62,63,63,63,63,63,63,64,64,64,64,64,64,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69};

// CALIBRATION_DEMOSAIC
static uint8_t _calibration_demosaic[]
 = {7,23,29,33,36,38,40,42,43,44,46,47,48,49,50,50,51,52,52,53,53,54,55,55,55,56,56,57,57,58,58,58,59,59,59,60,60,60,61,61,61,62,62,62,62,63,63,63,63,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66,67,67,67,67,67,67,68,68,68,68,68,68,69,69,69,69,69,69,69,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74};

// 8-bit normalised noise profile for WDR stitching
static uint8_t _calibration_wdr_np_lut[]
 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

// CALIBRATION_GAMMA
static uint16_t _calibration_gamma[]
 = {0,347,539,679,794,894,982,1062,1136,1204,1268,1329,1386,1441,1493,1543,1591,1638,1683,1726,1768,1809,1849,1888,1926,1963,1999,2034,2068,2102,2135,2168,2200,2231,2262,2292,2322,2351,2380,2408,2436,2463,2491,2517,2544,2570,2596,2621,2646,2671,2695,2719,2743,2767,2790,2814,2836,2859,2882,2904,2926,2948,2969,2990,3012,3033,3053,3074,3094,3115,3135,3155,3174,3194,3213,3233,3252,3271,3290,3308,3327,3345,3364,3382,3400,3418,3436,3453,3471,3488,3506,3523,3540,3557,3574,3591,3607,3624,3640,3657,3673,3689,3705,3721,3737,3753,3769,3785,3800,3816,3831,3846,3862,3877,3892,3907,3922,3937,3951,3966,3981,3995,4010,4024,4039,4053,4067,4081,4095};

// CALIBRATION_IRIDIX_ASYMMETRY
static uint32_t _calibration_iridix_asymmetry[] = {
    0, 61184, 116961, 168002, 214899, 258115, 298084, 335172, 369653, 401797, 431862, 460022, 486454, 511335, 534791, 556919, 577880, 597720, 616568, 634473, 651529, 667785, 683305, 698153, 712346, 725978, 739050, 751610, 763706, 775355, 786587, 797451, 807931, 818091, 827947, 837499, 846780, 855820, 864604, 873180, 881532, 889708, 897708, 905532, 913213, 920733, 928141, 935421, 942589, 949645, 956621, 963501, 970317, 977053, 983742, 990366, 996942, 1003470, 1009982, 1016446, 1022894, 1029326, 1035742, 1042158, 1048575,
};

// CALIBRATION_CA_FILTER_MEM
static uint32_t _calibration_ca_filter_mem[]
 = {32768,229629,491259,4278943225,4279204855,4262689525,4246239220,4229788915,4213338610,4196888050,4197214450,4180763890,4164313330,4147928050,4131477235,4115091955,4098641140,4082190325,4082516470,4066065655,4066391800,4066652665,4066913530,4067239930,4067500795,4084473340,4101445885,4118418430,4152037375,4185721855,4219340544,4253025024};

// calibration_awb_scene_presets in the following order AWB_DAY_LIGHT AWB_CLOUDY AWB_INCANDESCENT AWB_FLOURESCENT AWB_TWILIGHT AWB_SHADE AWB_WARM_FLOURESCENT
static uint16_t _calibration_awb_scene_presets[7][2] = {
  { 256, 256 },
  { 321, 231 },
  { 172, 334 },
  { 222, 274 },
  { 222, 274 },
  { 362, 216 },
  { 183, 314 }};

// CALIBRATION_CA_CORRECTION: MIN_CORRECTION, MESH_WIDTH, MESH_HEIGHT
static uint16_t _calibration_ca_correction[] = {1, 64, 64};


// CALIBRATION_CA_CORRECTION_MEM
static uint16_t _calibration_ca_correction_mem[][10] = {
  { 113, 7, 40, 4, 65355, 65495, 65511, 103, 20, 65456 },
  { 6, 83, 65529, 15, 65488, 65457, 65527, 42, 22, 65494 },
  { 65299, 65530, 65422, 65534, 372, 114, 59, 65404, 65481, 7 },
  { 65531, 65360, 6, 65452, 92, 171, 113, 65450, 65507, 65521 }};

static uint32_t _calibration_lut3d_mem[] = {0};

static uint32_t _calibration_decompander0_mem[] = {0, 32768, 65536, 98304, 131072, 163840, 196608, 229376, 262144, 294912, 327680, 360448, 393216, 425984, 458752, 491520, 524288, 557055, 589823, 622591, 655359, 688127, 720895, 753663, 786431, 819199, 851967, 884735, 917503, 950271, 983039, 1015807, 1048575};
static uint32_t _calibration_decompander1_mem[] = {0, 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440, 65536, 69632, 73728, 77824, 81920, 86016, 90112, 94208, 98304, 102400, 106496, 110592, 114688, 118784, 122880, 126976, 131072, 135168, 139264, 143360, 147456, 151552, 155648, 159744, 163840, 167936, 172032, 176128, 180224, 184320, 188416, 192512, 196608, 200704, 204800, 208896, 212992, 217088, 221184, 225280, 229376, 233472, 237568, 241664, 245760, 249856, 253952, 258048, 262144, 266240, 270336, 274432, 278528, 282624, 286720, 290816, 294912, 299008, 303104, 307200, 311296, 315392, 319488, 323584, 327680, 331776, 335872, 339968, 344064, 348160, 352256, 356352, 360448, 364544, 368640, 372736, 376832, 380928, 385024, 389120, 393216, 397312, 401408, 405504, 409600, 413696, 417792, 421888, 425984, 430080, 434176, 438272, 442368, 446464, 450560, 454656, 458752, 462848, 466944, 471040, 475136, 479232, 483328, 487424, 491520, 495616, 499712, 503808, 507904, 512000, 516096, 520192, 524288, 528383, 532479, 536575, 540671, 544767, 548863, 552959, 557055, 561151, 565247, 569343, 573439, 577535, 581631, 585727, 589823, 593919, 598015, 602111, 606207, 610303, 614399, 618495, 622591, 626687, 630783, 634879, 638975, 643071, 647167, 651263, 655359, 659455, 663551, 667647, 671743, 675839, 679935, 684031, 688127, 692223, 696319, 700415, 704511, 708607, 712703, 716799, 720895, 724991, 729087, 733183, 737279, 741375, 745471, 749567, 753663, 757759, 761855, 765951, 770047, 774143, 778239, 782335, 786431, 790527, 794623, 798719, 802815, 806911, 811007, 815103, 819199, 823295, 827391, 831487, 835583, 839679, 843775, 847871, 851967, 856063, 860159, 864255, 868351, 872447, 876543, 880639, 884735, 888831, 892927, 897023, 901119, 905215, 909311, 913407, 917503, 921599, 925695, 929791, 933887, 937983, 942079, 946175, 950271, 954367, 958463, 962559, 966655, 970751, 974847, 978943, 983039, 987135, 991231, 995327, 999423, 1003519, 1007615, 1011711, 1015807, 1019903, 1023999, 1028095, 1032191, 1036287, 1040383, 1044479, 1048575};

// CALIBRATION_SHADING_RADIAL_R
static uint16_t _calibration_shading_radial_r[] = {4096, 4113, 4130, 4147, 4164, 4182, 4199, 4216, 4234, 4251, 4269, 4286, 4304, 4322, 4340, 4357, 4375, 4393, 4411, 4430, 4448, 4466, 4484, 4503, 4521, 4540, 4558, 4577, 4596, 4614, 4633, 4652, 4671, 4690, 4709, 4728, 4747, 4767, 4786, 4805, 4825, 4844, 4864, 4883, 4903, 4923, 4943, 4963, 4983, 5003, 5023, 5043, 5063, 5084, 5104, 5124, 5145, 5165, 5186, 5207, 5227, 5248, 5269, 5290, 5311, 5332, 5354, 5375, 5396, 5417, 5439, 5460, 5482, 5504, 5526, 5547, 5569, 5591, 5613, 5635, 5658, 5680, 5702, 5725, 5747, 5770, 5793, 5815, 5838, 5861, 5884, 5907, 5930, 5954, 5977, 6001, 6024, 6048, 6072, 6095, 6119, 6143, 6167, 6192, 6216, 6240, 6265, 6290, 6314, 6339, 6364, 6389, 6415, 6440, 6465, 6491, 6517, 6542, 6568, 6594, 6621, 6647, 6673, 6700, 6727, 6754, 6781, 6808, 6835};

// CALIBRATION_SHADING_RADIAL_G
static uint16_t _calibration_shading_radial_g[] = {4096, 4108, 4120, 4133, 4145, 4157, 4170, 4182, 4195, 4207, 4220, 4233, 4246, 4258, 4271, 4284, 4297, 4310, 4323, 4336, 4350, 4363, 4376, 4389, 4403, 4416, 4430, 4443, 4457, 4471, 4485, 4498, 4512, 4526, 4540, 4554, 4568, 4582, 4596, 4611, 4625, 4639, 4654, 4668, 4682, 4697, 4712, 4726, 4741, 4756, 4771, 4785, 4800, 4815, 4830, 4845, 4860, 4876, 4891, 4906, 4922, 4937, 4952, 4968, 4983, 4999, 5015, 5030, 5046, 5062, 5078, 5094, 5110, 5126, 5142, 5158, 5174, 5191, 5207, 5223, 5240, 5256, 5273, 5290, 5306, 5323, 5340, 5357, 5374, 5391, 5408, 5425, 5442, 5459, 5477, 5494, 5512, 5529, 5547, 5564, 5582, 5600, 5618, 5636, 5654, 5672, 5690, 5708, 5726, 5745, 5763, 5782, 5800, 5819, 5838, 5857, 5876, 5895, 5914, 5933, 5952, 5972, 5991, 6011, 6031, 6051, 6070, 6090, 6111};

// CALIBRATION_SHADING_RADIAL_B
static uint16_t _calibration_shading_radial_b[] = {4096, 4107, 4118, 4128, 4139, 4150, 4161, 4172, 4183, 4194, 4205, 4216, 4228, 4239, 4250, 4261, 4272, 4284, 4295, 4307, 4318, 4329, 4341, 4352, 4364, 4376, 4387, 4399, 4411, 4422, 4434, 4446, 4458, 4470, 4482, 4493, 4505, 4517, 4530, 4542, 4554, 4566, 4578, 4590, 4603, 4615, 4627, 4640, 4652, 4664, 4677, 4689, 4702, 4714, 4727, 4740, 4752, 4765, 4778, 4791, 4803, 4816, 4829, 4842, 4855, 4868, 4881, 4894, 4908, 4921, 4934, 4947, 4960, 4974, 4987, 5001, 5014, 5028, 5041, 5055, 5068, 5082, 5096, 5110, 5123, 5137, 5151, 5165, 5179, 5193, 5207, 5221, 5236, 5250, 5264, 5279, 5293, 5308, 5322, 5337, 5351, 5366, 5381, 5396, 5411, 5426, 5441, 5456, 5471, 5486, 5501, 5517, 5532, 5548, 5563, 5579, 5595, 5610, 5626, 5642, 5658, 5674, 5691, 5707, 5723, 5740, 5756, 5773, 5790};


static LookupTable calibration_shading_radial_r = {.ptr = _calibration_shading_radial_r, .rows = 1, .cols = sizeof( _calibration_shading_radial_r ) / sizeof( _calibration_shading_radial_r[0] ), .width = sizeof( _calibration_shading_radial_r[0] )};
static LookupTable calibration_shading_radial_g = {.ptr = _calibration_shading_radial_g, .rows = 1, .cols = sizeof( _calibration_shading_radial_g ) / sizeof( _calibration_shading_radial_g[0] ), .width = sizeof( _calibration_shading_radial_g[0] )};
static LookupTable calibration_shading_radial_b = {.ptr = _calibration_shading_radial_b, .rows = 1, .cols = sizeof( _calibration_shading_radial_b ) / sizeof( _calibration_shading_radial_b[0] ), .width = sizeof( _calibration_shading_radial_b[0] )};
static LookupTable calibration_decompander0_mem = {.ptr = _calibration_decompander0_mem, .rows = 1, .cols = sizeof( _calibration_decompander0_mem ) / sizeof( _calibration_decompander0_mem[0] ), .width = sizeof( _calibration_decompander0_mem[0] )};
static LookupTable calibration_decompander1_mem = {.ptr = _calibration_decompander1_mem, .rows = 1, .cols = sizeof( _calibration_decompander1_mem ) / sizeof( _calibration_decompander1_mem[0] ), .width = sizeof( _calibration_decompander1_mem[0] )};

static LookupTable calibration_awb_scene_presets = {.ptr = _calibration_awb_scene_presets, .cols = 2, .rows = sizeof( _calibration_awb_scene_presets ) / sizeof( _calibration_awb_scene_presets[0] ), .width = sizeof( _calibration_awb_scene_presets[0][0] )};
static LookupTable calibration_light_src = {.ptr = _calibration_light_src, .cols = 2, .rows = sizeof( _calibration_light_src ) / sizeof( _calibration_light_src[0] ), .width = sizeof( _calibration_light_src[0][0] )};
static LookupTable calibration_rg_pos = {.ptr = _calibration_rg_pos, .rows = 1, .cols = sizeof( _calibration_rg_pos ) / sizeof( _calibration_rg_pos[0] ), .width = sizeof( _calibration_rg_pos[0] )};
static LookupTable calibration_bg_pos = {.ptr = _calibration_bg_pos, .rows = 1, .cols = sizeof( _calibration_bg_pos ) / sizeof( _calibration_bg_pos[0] ), .width = sizeof( _calibration_bg_pos[0] )};
static LookupTable calibration_mesh_rgbg_weight = {.ptr = _calibration_mesh_rgbg_weight, .cols = 15, .rows = sizeof( _calibration_mesh_rgbg_weight ) / sizeof( _calibration_mesh_rgbg_weight[0] ), .width = sizeof( _calibration_mesh_rgbg_weight[0][0] )};
static LookupTable calibration_mesh_ls_weight = {.ptr = _calibration_mesh_ls_weight, .cols = 15, .rows = sizeof( _calibration_mesh_ls_weight ) / sizeof( _calibration_mesh_ls_weight[0] ), .width = sizeof( _calibration_mesh_ls_weight[0][0] )};
static LookupTable calibration_mesh_color_temperature = {.ptr = _calibration_mesh_color_temperature, .cols = 15, .rows = sizeof( _calibration_mesh_color_temperature ) / sizeof( _calibration_mesh_color_temperature[0] ), .width = sizeof( _calibration_mesh_color_temperature[0][0] )};
static LookupTable calibration_wb_strength = {.ptr = _calibration_wb_strength, .rows = 1, .cols = sizeof( _calibration_wb_strength ) / sizeof( _calibration_wb_strength[0] ), .width = sizeof( _calibration_wb_strength[0] )};
static LookupTable calibration_sky_lux_th = {.ptr = _calibration_sky_lux_th, .rows = 1, .cols = sizeof( _calibration_sky_lux_th ) / sizeof( _calibration_sky_lux_th[0] ), .width = sizeof( _calibration_sky_lux_th[0] )};
static LookupTable calibration_ct_rg_pos_calc = {.ptr = _calibration_ct_rg_pos_calc, .rows = 1, .cols = sizeof( _calibration_ct_rg_pos_calc ) / sizeof( _calibration_ct_rg_pos_calc[0] ), .width = sizeof( _calibration_ct_rg_pos_calc[0] )};
static LookupTable calibration_ct_bg_pos_calc = {.ptr = _calibration_ct_bg_pos_calc, .rows = 1, .cols = sizeof( _calibration_ct_bg_pos_calc ) / sizeof( _calibration_ct_bg_pos_calc[0] ), .width = sizeof( _calibration_ct_bg_pos_calc[0] )};
static LookupTable calibration_color_temp = {.ptr = _calibration_color_temp, .rows = 1, .cols = sizeof( _calibration_color_temp ) / sizeof( _calibration_color_temp[0] ), .width = sizeof( _calibration_color_temp[0] )};
static LookupTable calibration_ct65pos = {.ptr = _calibration_ct65pos, .rows = 1, .cols = sizeof( _calibration_ct65pos ) / sizeof( _calibration_ct65pos[0] ), .width = sizeof( _calibration_ct65pos[0] )};
static LookupTable calibration_ct40pos = {.ptr = _calibration_ct40pos, .rows = 1, .cols = sizeof( _calibration_ct40pos ) / sizeof( _calibration_ct40pos[0] ), .width = sizeof( _calibration_ct40pos[0] )};
static LookupTable calibration_ct30pos = {.ptr = _calibration_ct30pos, .rows = 1, .cols = sizeof( _calibration_ct30pos ) / sizeof( _calibration_ct30pos[0] ), .width = sizeof( _calibration_ct30pos[0] )};
static LookupTable calibration_evtolux_ev_lut = {.ptr = _calibration_evtolux_ev_lut, .rows = 1, .cols = sizeof( _calibration_evtolux_ev_lut ) / sizeof( _calibration_evtolux_ev_lut[0] ), .width = sizeof( _calibration_evtolux_ev_lut[0] )};
static LookupTable calibration_evtolux_lux_lut = {.ptr = _calibration_evtolux_lux_lut, .rows = 1, .cols = sizeof( _calibration_evtolux_lux_lut ) / sizeof( _calibration_evtolux_lux_lut[0] ), .width = sizeof( _calibration_evtolux_lux_lut[0] )};
static LookupTable calibration_black_level_r = {.ptr = _calibration_black_level_r, .cols = 2, .rows = sizeof( _calibration_black_level_r ) / sizeof( _calibration_black_level_r[0] ), .width = sizeof( _calibration_black_level_r[0][0] )};
static LookupTable calibration_black_level_gr = {.ptr = _calibration_black_level_gr, .cols = 2, .rows = sizeof( _calibration_black_level_gr ) / sizeof( _calibration_black_level_gr[0] ), .width = sizeof( _calibration_black_level_gr[0][0] )};
static LookupTable calibration_black_level_gb = {.ptr = _calibration_black_level_gb, .cols = 2, .rows = sizeof( _calibration_black_level_gb ) / sizeof( _calibration_black_level_gb[0] ), .width = sizeof( _calibration_black_level_gb[0][0] )};
static LookupTable calibration_black_level_b = {.ptr = _calibration_black_level_b, .cols = 2, .rows = sizeof( _calibration_black_level_b ) / sizeof( _calibration_black_level_b[0] ), .width = sizeof( _calibration_black_level_b[0][0] )};
static LookupTable calibration_static_wb = {.ptr = _calibration_static_wb, .rows = 1, .cols = sizeof( _calibration_static_wb ) / sizeof( _calibration_static_wb[0] ), .width = sizeof( _calibration_static_wb[0] )};
static LookupTable calibration_mt_absolute_ls_a_ccm = {.ptr = _calibration_mt_absolute_ls_a_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_a_ccm ) / sizeof( _calibration_mt_absolute_ls_a_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_a_ccm[0] )};
static LookupTable calibration_mt_absolute_ls_d40_ccm = {.ptr = _calibration_mt_absolute_ls_d40_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_d40_ccm ) / sizeof( _calibration_mt_absolute_ls_d40_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_d40_ccm[0] )};
static LookupTable calibration_mt_absolute_ls_d50_ccm = {.ptr = _calibration_mt_absolute_ls_d50_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_d50_ccm ) / sizeof( _calibration_mt_absolute_ls_d50_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_d50_ccm[0] )};
static LookupTable calibration_shading_ls_a_r = {.ptr = _calibration_shading_ls_a_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_r ) / sizeof( _calibration_shading_ls_a_r[0] ), .width = sizeof( _calibration_shading_ls_a_r[0] )};
static LookupTable calibration_shading_ls_a_g = {.ptr = _calibration_shading_ls_a_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_g ) / sizeof( _calibration_shading_ls_a_g[0] ), .width = sizeof( _calibration_shading_ls_a_g[0] )};
static LookupTable calibration_shading_ls_a_b = {.ptr = _calibration_shading_ls_a_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_b ) / sizeof( _calibration_shading_ls_a_b[0] ), .width = sizeof( _calibration_shading_ls_a_b[0] )};
static LookupTable calibration_shading_ls_tl84_r = {.ptr = _calibration_shading_ls_tl84_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_r ) / sizeof( _calibration_shading_ls_tl84_r[0] ), .width = sizeof( _calibration_shading_ls_tl84_r[0] )};
static LookupTable calibration_shading_ls_tl84_g = {.ptr = _calibration_shading_ls_tl84_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_g ) / sizeof( _calibration_shading_ls_tl84_g[0] ), .width = sizeof( _calibration_shading_ls_tl84_g[0] )};
static LookupTable calibration_shading_ls_tl84_b = {.ptr = _calibration_shading_ls_tl84_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_b ) / sizeof( _calibration_shading_ls_tl84_b[0] ), .width = sizeof( _calibration_shading_ls_tl84_b[0] )};
static LookupTable calibration_shading_ls_d65_r = {.ptr = _calibration_shading_ls_d65_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_r ) / sizeof( _calibration_shading_ls_d65_r[0] ), .width = sizeof( _calibration_shading_ls_d65_r[0] )};
static LookupTable calibration_shading_ls_d65_g = {.ptr = _calibration_shading_ls_d65_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_g ) / sizeof( _calibration_shading_ls_d65_g[0] ), .width = sizeof( _calibration_shading_ls_d65_g[0] )};
static LookupTable calibration_shading_ls_d65_b = {.ptr = _calibration_shading_ls_d65_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_b ) / sizeof( _calibration_shading_ls_d65_b[0] ), .width = sizeof( _calibration_shading_ls_d65_b[0] )};
static LookupTable calibration_awb_warming_ls_a = {.ptr = _calibration_awb_warming_ls_a, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_a ) / sizeof( _calibration_awb_warming_ls_a[0] ), .width = sizeof( _calibration_awb_warming_ls_a[0] )};
static LookupTable calibration_awb_warming_ls_d50 = {.ptr = _calibration_awb_warming_ls_d50, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_d50 ) / sizeof( _calibration_awb_warming_ls_d50[0] ), .width = sizeof( _calibration_awb_warming_ls_d50[0] )};
static LookupTable calibration_awb_warming_ls_d75 = {.ptr = _calibration_awb_warming_ls_d75, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_d75 ) / sizeof( _calibration_awb_warming_ls_d75[0] ), .width = sizeof( _calibration_awb_warming_ls_d75[0] )};
static LookupTable calibration_noise_profile = {.ptr = _calibration_noise_profile, .rows = 1, .cols = sizeof( _calibration_noise_profile ) / sizeof( _calibration_noise_profile[0] ), .width = sizeof( _calibration_noise_profile[0] )};
static LookupTable calibration_demosaic = {.ptr = _calibration_demosaic, .rows = 1, .cols = sizeof( _calibration_demosaic ) / sizeof( _calibration_demosaic[0] ), .width = sizeof( _calibration_demosaic[0] )};
static LookupTable calibration_wdr_np_lut = {.ptr = _calibration_wdr_np_lut, .rows = 1, .cols = sizeof( _calibration_wdr_np_lut ) / sizeof( _calibration_wdr_np_lut[0] ), .width = sizeof( _calibration_wdr_np_lut[0] )};
static LookupTable calibration_gamma = {.ptr = _calibration_gamma, .rows = 1, .cols = sizeof( _calibration_gamma ) / sizeof( _calibration_gamma[0] ), .width = sizeof( _calibration_gamma[0] )};
static LookupTable calibration_iridix_asymmetry = {.ptr = _calibration_iridix_asymmetry, .rows = 1, .cols = sizeof( _calibration_iridix_asymmetry ) / sizeof( _calibration_iridix_asymmetry[0] ), .width = sizeof( _calibration_iridix_asymmetry[0] )};
static LookupTable calibration_ca_filter_mem = {.ptr = _calibration_ca_filter_mem, .rows = 1, .cols = sizeof( _calibration_ca_filter_mem ) / sizeof( _calibration_ca_filter_mem[0] ), .width = sizeof( _calibration_ca_filter_mem[0] )};
static LookupTable calibration_ca_correction = {.ptr = _calibration_ca_correction, .rows = 1, .cols = sizeof( _calibration_ca_correction ) / sizeof( _calibration_ca_correction[0] ), .width = sizeof( _calibration_ca_correction[0] )};
static LookupTable calibration_ca_correction_mem = {.ptr = _calibration_ca_correction_mem, .cols = 10, .rows = sizeof( _calibration_ca_correction_mem ) / sizeof( _calibration_ca_correction_mem[0] ), .width = sizeof( _calibration_ca_correction_mem[0][0] )};
static LookupTable calibration_lut3d_mem = {.ptr = _calibration_lut3d_mem, .rows = 1, .cols = sizeof( _calibration_lut3d_mem ) / sizeof( _calibration_lut3d_mem[0] ), .width = sizeof( _calibration_lut3d_mem[0] )};

uint32_t get_calibrations_static_linear_ov13858( ACameraCalibrations *c )
{
    uint32_t result = 0;
    if ( c != 0 ) {
        c->calibrations[CALIBRATION_SHADING_RADIAL_R] = &calibration_shading_radial_r;
        c->calibrations[CALIBRATION_SHADING_RADIAL_G] = &calibration_shading_radial_g;
        c->calibrations[CALIBRATION_SHADING_RADIAL_B] = &calibration_shading_radial_b;
        c->calibrations[CALIBRATION_DECOMPANDER0_MEM] = &calibration_decompander0_mem;
        c->calibrations[CALIBRATION_DECOMPANDER1_MEM] = &calibration_decompander1_mem;
        c->calibrations[CALIBRATION_LIGHT_SRC] = &calibration_light_src;
        c->calibrations[CALIBRATION_RG_POS] = &calibration_rg_pos;
        c->calibrations[CALIBRATION_BG_POS] = &calibration_bg_pos;
        c->calibrations[CALIBRATION_MESH_RGBG_WEIGHT] = &calibration_mesh_rgbg_weight;
        c->calibrations[CALIBRATION_MESH_LS_WEIGHT] = &calibration_mesh_ls_weight;
        c->calibrations[CALIBRATION_MESH_COLOR_TEMPERATURE] = &calibration_mesh_color_temperature;
        c->calibrations[CALIBRATION_WB_STRENGTH] = &calibration_wb_strength;
        c->calibrations[CALIBRATION_SKY_LUX_TH] = &calibration_sky_lux_th;
        c->calibrations[CALIBRATION_CT_RG_POS_CALC] = &calibration_ct_rg_pos_calc;
        c->calibrations[CALIBRATION_CT_BG_POS_CALC] = &calibration_ct_bg_pos_calc;
        c->calibrations[CALIBRATION_COLOR_TEMP] = &calibration_color_temp;
        c->calibrations[CALIBRATION_CT65POS] = &calibration_ct65pos;
        c->calibrations[CALIBRATION_CT40POS] = &calibration_ct40pos;
        c->calibrations[CALIBRATION_CT30POS] = &calibration_ct30pos;
        c->calibrations[CALIBRATION_EVTOLUX_EV_LUT] = &calibration_evtolux_ev_lut;
        c->calibrations[CALIBRATION_EVTOLUX_LUX_LUT] = &calibration_evtolux_lux_lut;
        c->calibrations[CALIBRATION_BLACK_LEVEL_R] = &calibration_black_level_r;
        c->calibrations[CALIBRATION_BLACK_LEVEL_GR] = &calibration_black_level_gr;
        c->calibrations[CALIBRATION_BLACK_LEVEL_GB] = &calibration_black_level_gb;
        c->calibrations[CALIBRATION_BLACK_LEVEL_B] = &calibration_black_level_b;
        c->calibrations[CALIBRATION_STATIC_WB] = &calibration_static_wb;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_A_CCM] = &calibration_mt_absolute_ls_a_ccm;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_D40_CCM] = &calibration_mt_absolute_ls_d40_ccm;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_D50_CCM] = &calibration_mt_absolute_ls_d50_ccm;
        c->calibrations[CALIBRATION_SHADING_LS_A_R] = &calibration_shading_ls_a_r;
        c->calibrations[CALIBRATION_SHADING_LS_A_G] = &calibration_shading_ls_a_g;
        c->calibrations[CALIBRATION_SHADING_LS_A_B] = &calibration_shading_ls_a_b;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_R] = &calibration_shading_ls_tl84_r;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_G] = &calibration_shading_ls_tl84_g;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_B] = &calibration_shading_ls_tl84_b;
        c->calibrations[CALIBRATION_SHADING_LS_D65_R] = &calibration_shading_ls_d65_r;
        c->calibrations[CALIBRATION_SHADING_LS_D65_G] = &calibration_shading_ls_d65_g;
        c->calibrations[CALIBRATION_SHADING_LS_D65_B] = &calibration_shading_ls_d65_b;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_A] = &calibration_awb_warming_ls_a;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_D50] = &calibration_awb_warming_ls_d50;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_D75] = &calibration_awb_warming_ls_d75;
        c->calibrations[CALIBRATION_NOISE_PROFILE] = &calibration_noise_profile;
        c->calibrations[CALIBRATION_DEMOSAIC] = &calibration_demosaic;
        c->calibrations[CALIBRATION_WDR_NP_LUT] = &calibration_wdr_np_lut;
        c->calibrations[CALIBRATION_GAMMA] = &calibration_gamma;
        c->calibrations[CALIBRATION_IRIDIX_ASYMMETRY] = &calibration_iridix_asymmetry;
        c->calibrations[CALIBRATION_AWB_SCENE_PRESETS] = &calibration_awb_scene_presets;
        c->calibrations[CALIBRATION_CA_FILTER_MEM] = &calibration_ca_filter_mem;
        c->calibrations[CALIBRATION_CA_CORRECTION] = &calibration_ca_correction;
        c->calibrations[CALIBRATION_CA_CORRECTION_MEM] = &calibration_ca_correction_mem;
        c->calibrations[CALIBRATION_LUT3D_MEM] = &calibration_lut3d_mem;
    } else {
        result = -1;
    }
    return result;
}
